package com.sz.wechat.controller;

import com.sz.wechat.entity.User;
import com.sz.wechat.mapper.UserMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "朋友管理", description = "朋友相关的API")
@RestController
@RequestMapping("/friends")
public class FriendController {

    @Autowired
    private UserMapper userMapper;

    @Operation(summary = "获取所有朋友", description = "获取所有朋友信息", tags = {"朋友管理"})
    @GetMapping
    public List<User> getAllFriends() {
        return userMapper.selectList(null);
    }

    @Operation(summary = "删除朋友", description = "根据用户ID删除朋友", tags = {"朋友管理"})
    @DeleteMapping("/{id}")
    public int deleteFriend(@PathVariable Long id) {
        return userMapper.deleteUserById(id);
    }
}
